package nc.ui.eh.ehld.p103001;

import java.awt.Container;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.ArrayList;

import nc.ui.pub.bill.BillItem;
import nc.ui.pub.bill.IBillModelRowStateChangeEventListener;
import nc.ui.pub.bill.RowStateChangeEvent;
import nc.ui.scm.pub.sourceref.BillRefListPanel;
import nc.ui.scm.pub.sourceref.BillToBillRefPanel;
import nc.ui.scm.pub.sourceref.IBillReferQueryProxy;
import nc.ui.scm.pub.sourceref.IBillToBillListPanel;
import nc.ui.scm.pub.sourceref.SimpBillRefListPanel;
import nc.ui.scm.pub.sourceref.SourceRefDlg;
import nc.ui.scm.pub.sourceref.BillToBillRefPanel.ShowState;
import nc.ui.scm.util.ObjectUtils;
import nc.vo.jcom.lang.StringUtil;
import nc.vo.pub.AggregatedValueObject;
import nc.vo.pub.bill.BillTempletBodyVO;
import nc.vo.pub.bill.BillTempletVO;
//nc.ui.pub.pf.BillSourceDLG
public class test extends SourceRefDlg {

	public test(String arg0, String arg1, String arg2, String arg3, String arg4, String arg5, String arg6, String arg7, String arg8, String arg9, Object arg10, Container arg11) {
		super(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11);
		// TODO Auto-generated constructor stub
	}

	public test(String arg0, String arg1, String arg2, String arg3, String arg4, String arg5, String arg6, String arg7, String arg8, Container arg9) {
		super(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9);
		// TODO Auto-generated constructor stub
	}
	@Override
	protected BillRefListPanel createDoubleTableListPanel() {
		// TODO Auto-generated method stub
		return new b(getBusinessType(), getBillType(), getCurrentBillType(),
				getPkCorp());
	}

	@Override
	protected SimpBillRefListPanel createOneTableListPanel() {
		// TODO Auto-generated method stub
		return new c(getBusinessType(), getBillType(), getCurrentBillType(),
				getPkCorp());
	}
	@Override
	protected BillToBillRefPanel createBillToBillRefPanel() {
		// TODO Auto-generated method stub
		try{
		      billtobillrefpanel = new BillToBillRefPanel();
		      BillRefListPanel billref = createDoubleTableListPanel(); 
		      SimpBillRefListPanel simpbillref = createOneTableListPanel();
		     
		      BillTempletVO tvo = billref.getDefaultTemplet(getBillType(), getBusinessType(),
		          getOperator(), getPkCorp(),billref.getRefNodeCode());
		      tvo = (BillTempletVO)ObjectUtils.serializableClone(tvo);
		      BillTempletBodyVO[] bvos = tvo.getBodyVO();
		      ArrayList<BillTempletBodyVO> listvos = new ArrayList<BillTempletBodyVO>();
		      for(BillTempletBodyVO bvo : bvos){
		        if(bvo.getPos()!=null && bvo.getPos().intValue() == BillItem.BODY 
		            && bvo.getTable_code()!=null && !bvo.getTable_code().equals("ehzg_sale_contract_b"))
		          continue;
		        listvos.add(bvo);
		      }
		      tvo.setChildrenVO(listvos.toArray(new BillTempletBodyVO[listvos.size()]));
		      billref.createBillListPanel(tvo);
		      simpbillref.createBillListPanel(tvo);
		      billtobillrefpanel.createUI(billref, simpbillref);
		      if(getQueyDlg()!=null && (getQueyDlg() instanceof IBillReferQueryProxy)){
		        if(((IBillReferQueryProxy)getQueyDlg()).isShowDoubleTableRef()){
		          billtobillrefpanel.switchShow(ShowState.DoubleTable);
		        }else{
		          billtobillrefpanel.switchShow(ShowState.OneTable);
		        }
		      }
//		      IBillToBillListPanel billListPanel=billtobillrefpanel.getCurBillListPanel();
//		      BillRefListPanel listPanel=(BillRefListPanel)billListPanel;
		      
		      return billtobillrefpanel;
		    }catch(Exception e){
		      handleException(e);
		      return null;
		    }
	}

}
